9. UC-SLS Lecture 9 : Assembly : Operations and Data Types#

9.1. A simple mov.S program#

9.1.1. Setup#

  • create a directory mkdir mov; cd mov

  • create and write mov.S below

  • add a Makefile to automate assembling and linking

    • we are going run the commands by hand this time to highlight the details

  • add our setup.gdb to make working in gdb easier

  • normally you would want to track everything in git

CODE: asm - mov.S

	.intel_syntax noprefix
	.text
	
	.equ EXIT_SYSCALL_NR,60
	
	.global _start
	.type _start, @function	
_start:
	mov rax, 0b1000

	mov rax, EXIT_SYSCALL_NR
	mov rdi, 2
	syscall
	
	

9.1.2. Assemble mov.S into mov.o directly with assembler (as)#

  • -a produce listing to standard out

  • we could add -g flag to add extra debugger information but lets skip it for now

9.1.2.1. mov.o is NOT an executable#

9.1.2.2. What kind of file is is it?#

9.1.2.3. Examine Symbol Table#

9.1.4. gdb -tui mov -x setup.gdb #

9.1.4.1. rebuild with more debug info -g#

Debug